﻿using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CloudShot.Properties;

namespace CloudShot.Forms
{
  public sealed partial class HotkeyOccupiedDialog : Form
  {
    public HotkeyOccupiedDialog(IEnumerable<string> errors, Icon dialogIcon, bool showSettingsButton = true)
    {
      InitializeComponent();
      
      Icon = Resources.applicationIcon;
      Text = Application.ProductName;

      iconPictureBox.Image = dialogIcon != null ? dialogIcon.ToBitmap() : null;
      lblMessage.Text = GetErrorMessage(errors);
      btnSettings.Visible = showSettingsButton;
    }

    private static string GetErrorMessage(IEnumerable<string> errors)
    {
      var errorMessage = new StringBuilder();
      errorMessage.AppendLine(Resources.HotkeyOccupiedDialog_OccupiedHotkeysHeader);
      errorMessage.AppendLine();

      foreach (string err in errors)
      {
        errorMessage.AppendLine(err);
      }

      errorMessage.AppendLine();
      errorMessage.Append(Resources.HotkeyOccupiedDialog_OccupiedHotkeysFooter);

      return errorMessage.ToString();
    }
  }
}
